#import "Player.h"

@interface Player ()

@property (nonatomic,readwrite) NSString* name;
@property (readwrite) NSInteger reactionScore;
@property (readwrite) NSInteger knowledgeScore;
@property (readwrite) NSInteger observationScore;
@property (readwrite) NSInteger efficiency;
@property (readwrite) NSInteger unefficiency;

@end

@implementation Player

- (instancetype)initWithName:(NSString *)name
{
    self = [super init];
    if (self) {
        self.name=name;
        self.reactionScore=0;
        self.knowledgeScore=0;
        self.observationScore=0;
        self.efficiency = 0;
    }
    return self;
}

-(void)setName:(NSString *)name{
    if (name && ![name isEqualToString:@""]) {
        _name=name;
    }
    else{
        _name=@"No Name";
    }
}

-(NSInteger)totalScore{
    return self.reactionScore + self.knowledgeScore + self.observationScore;
}

-(void)increaseScoreWithType:(GameCategory)type{
    self.efficiency++;
    if (type == 0) {
        self.reactionScore++;
    }
    else if (type == 1) {
        self.knowledgeScore++;
    }
    else {
        self.observationScore++;
    }
    
}

-(void)decreaseScoreWithType:(GameCategory)type{
    self.unefficiency++;
    if (type == 0) {
        self.reactionScore--;
    }
    else if (type == 1) {
        self.knowledgeScore--;
    }
    else {
        self.observationScore--;
    }
}

@end
